using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class PurchaseRequisitionInfo
    {
		#region Local Variable
		private Int32 _Reference;
		public Int32 Reference
		{
			get { return _Reference; }
			set { _Reference = value; }
		}
		private String _InvNo;
		public String InvNo
		{
			get { return _InvNo; }
			set { _InvNo = value; }
		}
		private String _Creditor;
		public String Creditor
		{
			get { return _Creditor; }
			set { _Creditor = value; }
		}
		private String _OurRef;
		public String OurRef
		{
			get { return _OurRef; }
			set { _OurRef = value; }
		}
		private DateTime _IssueDate;
		public DateTime IssueDate
		{
			get { return _IssueDate; }
			set { _IssueDate = value; }
		}
		private DateTime _ReceiptDate;
		public DateTime ReceiptDate
		{
			get { return _ReceiptDate; }
			set { _ReceiptDate = value; }
		}
		private Double _Amt;
		public Double Amt
		{
			get { return _Amt; }
			set { _Amt = value; }
		}
		private Double _OtherAmt;
		public Double OtherAmt
		{
			get { return _OtherAmt; }
			set { _OtherAmt = value; }
		}
		private String _Currency;
		public String Currency
		{
			get { return _Currency; }
			set { _Currency = value; }
		}
		private String _PymtRef;
		public String PymtRef
		{
			get { return _PymtRef; }
			set { _PymtRef = value; }
		}
		private DateTime _PaidDate;
		public DateTime PaidDate
		{
			get { return _PaidDate; }
			set { _PaidDate = value; }
		}
		private Int32 _PaymentTerm;
		public Int32 PaymentTerm
		{
			get { return _PaymentTerm; }
			set { _PaymentTerm = value; }
		}
		private DateTime _DueDate;
		public DateTime DueDate
		{
			get { return _DueDate; }
			set { _DueDate = value; }
		}
		private String _Description;
		public String Description
		{
			get { return _Description; }
			set { _Description = value; }
		}
		private String _Contract;
		public String Contract
		{
			get { return _Contract; }
			set { _Contract = value; }
		}
		private DateTime _DeliveryDate;
		public DateTime DeliveryDate
		{
			get { return _DeliveryDate; }
			set { _DeliveryDate = value; }
		}
		private DateTime _ReturnedDate;
		public DateTime ReturnedDate
		{
			get { return _ReturnedDate; }
			set { _ReturnedDate = value; }
		}
		private String _Department;
		public String Department
		{
			get { return _Department; }
			set { _Department = value; }
		}
		private String _Remark1;
		public String Remark1
		{
			get { return _Remark1; }
			set { _Remark1 = value; }
		}
		private String _Remark2;
		public String Remark2
		{
			get { return _Remark2; }
			set { _Remark2 = value; }
		}
		private String _Remark3;
		public String Remark3
		{
			get { return _Remark3; }
			set { _Remark3 = value; }
		}
		private Int16 _Mark;
		public Int16 Mark
		{
			get { return _Mark; }
			set { _Mark = value; }
		}
		private String _TransMitRef;
		public String TransMitRef
		{
			get { return _TransMitRef; }
			set { _TransMitRef = value; }
		}
		private DateTime _TransMitDate;
		public DateTime TransMitDate
		{
			get { return _TransMitDate; }
			set { _TransMitDate = value; }
		}
		private Int16 _MarkTrm;
		public Int16 MarkTrm
		{
			get { return _MarkTrm; }
			set { _MarkTrm = value; }
		}
		private String _TransMitStat;
		public String TransMitStat
		{
			get { return _TransMitStat; }
			set { _TransMitStat = value; }
		}
		private String _Receiver;
		public String Receiver
		{
			get { return _Receiver; }
			set { _Receiver = value; }
		}
		private String _VendorCode;
		public String VendorCode
		{
			get { return _VendorCode; }
			set { _VendorCode = value; }
		}
		private Int16 _LineNo;
		public Int16 LineNo
		{
			get { return _LineNo; }
			set { _LineNo = value; }
		}
		private Double _CvtRate;
		public Double CvtRate
		{
			get { return _CvtRate; }
			set { _CvtRate = value; }
		}
		private String _ReturnRef;
		public String ReturnRef
		{
			get { return _ReturnRef; }
			set { _ReturnRef = value; }
		}
		private Int32 _aYear;
		public Int32 aYear
		{
			get { return _aYear; }
			set { _aYear = value; }
		}
		private String _RealContract;
		public String RealContract
		{
			get { return _RealContract; }
			set { _RealContract = value; }
		}
		private String _CreatedBy;
		public String CreatedBy
		{
			get { return _CreatedBy; }
			set { _CreatedBy = value; }
		}
		private String _ModifiedBy;
		public String ModifiedBy
		{
			get { return _ModifiedBy; }
			set { _ModifiedBy = value; }
		}
		private DateTime _CreatedDate;
		public DateTime CreatedDate
		{
			get { return _CreatedDate; }
			set { _CreatedDate = value; }
		}
		private DateTime _ModifiedDate;
		public DateTime ModifiedDate
		{
			get { return _ModifiedDate; }
			set { _ModifiedDate = value; }
		}
        #endregion LocalVariable
        
        #region Constructor
		public PurchaseRequisitionInfo()
		{
			_Reference = -1;
			_InvNo = "";
			_Creditor = "";
			_OurRef = "";
			_IssueDate = DateTime.Now;
			_ReceiptDate = DateTime.Now;
			_Amt = 0;
			_OtherAmt = 0;
			_Currency = "";
			_PymtRef = "";
			_PaidDate = DateTime.Now;
			_PaymentTerm = -1;
			_DueDate = DateTime.Now;
			_Description = "";
			_Contract = "";
			_DeliveryDate = DateTime.Now;
			_ReturnedDate = DateTime.Now;
			_Department = "";
			_Remark1 = "";
			_Remark2 = "";
			_Remark3 = "";
			_Mark = (Int16)0;
			_TransMitRef = "";
			_TransMitDate = DateTime.Now;
			_MarkTrm = (Int16)0;
			_TransMitStat = "";
			_Receiver = "";
			_VendorCode = "";
			_LineNo = (Int16)0;
			_CvtRate = 0;
			_ReturnRef = "";
			_aYear = -1;
			_RealContract = "";
			_CreatedBy = "";
			_ModifiedBy = "";
			_CreatedDate = DateTime.Now;
			_ModifiedDate = DateTime.Now;
		}
        public PurchaseRequisitionInfo(PurchaseRequisitionInfo obj)
            
        {
            _Reference = obj.Reference;
            _InvNo = obj.InvNo;
            _Creditor = obj.Creditor;
            _OurRef = obj.OurRef;
            _IssueDate = obj.IssueDate;
            _ReceiptDate = obj.ReceiptDate;
            _Amt = obj.Amt;
            _OtherAmt = obj.OtherAmt;
            _Currency = obj.Currency;
            _PymtRef = obj.PymtRef;
            _PaidDate = obj.PaidDate;
            _PaymentTerm = obj.PaymentTerm;
            _DueDate = obj.DueDate;
            _Description = obj.Description;
            _Contract = obj.Contract;
            _DeliveryDate = obj.DeliveryDate;
            _ReturnedDate = obj.ReturnedDate;
            _Department = obj.Department;
            _Remark1 = obj.Remark1;
            _Remark2 = obj.Remark2;
            _Remark3 = obj.Remark3;
            _Mark = Mark;
            _TransMitRef = obj.TransMitRef;
            _TransMitDate = obj.TransMitDate;
            _MarkTrm = obj.MarkTrm;
            _TransMitStat = obj.TransMitStat;
            _Receiver = obj.Receiver;
            _VendorCode = obj.VendorCode;
            _LineNo = obj.LineNo;
            _CvtRate = obj.CvtRate;
            _ReturnRef = obj.ReturnRef;
            _aYear = obj.aYear;
            _RealContract = obj.RealContract;
            _CreatedBy = obj.CreatedBy;
            _ModifiedBy = obj.ModifiedBy;
            _CreatedDate = obj.CreatedDate;
            _ModifiedDate = obj.ModifiedDate;
        }
		public PurchaseRequisitionInfo(
			Int32 Reference,
			String InvNo,
			String Creditor,
			String OurRef,
			DateTime IssueDate,
			DateTime ReceiptDate,
			Double Amt,
			Double OtherAmt,
			String Currency,
			String PymtRef,
			DateTime PaidDate,
			Int32 PaymentTerm,
			DateTime DueDate,
			String Description,
			String Contract,
			DateTime DeliveryDate,
			DateTime ReturnedDate,
			String Department,
			String Remark1,
			String Remark2,
			String Remark3,
			Int16 Mark,
			String TransMitRef,
			DateTime TransMitDate,
			Int16 MarkTrm,
			String TransMitStat,
			String Receiver,
			String VendorCode,
			Int16 LineNo,
			Double CvtRate,
			String ReturnRef,
			Int32 aYear,
			String RealContract,
			String CreatedBy,
			String ModifiedBy,
			DateTime CreatedDate,
			DateTime ModifiedDate
			)
		{
			_Reference = Reference;
			_InvNo = InvNo;
			_Creditor = Creditor;
			_OurRef = OurRef;
			_IssueDate = IssueDate;
			_ReceiptDate = ReceiptDate;
			_Amt = Amt;
			_OtherAmt = OtherAmt;
			_Currency = Currency;
			_PymtRef = PymtRef;
			_PaidDate = PaidDate;
			_PaymentTerm = PaymentTerm;
			_DueDate = DueDate;
			_Description = Description;
			_Contract = Contract;
			_DeliveryDate = DeliveryDate;
			_ReturnedDate = ReturnedDate;
			_Department = Department;
			_Remark1 = Remark1;
			_Remark2 = Remark2;
			_Remark3 = Remark3;
			_Mark = Mark;
			_TransMitRef = TransMitRef;
			_TransMitDate = TransMitDate;
			_MarkTrm = MarkTrm;
			_TransMitStat = TransMitStat;
			_Receiver = Receiver;
			_VendorCode = VendorCode;
			_LineNo = LineNo;
			_CvtRate = CvtRate;
			_ReturnRef = ReturnRef;
			_aYear = aYear;
			_RealContract = RealContract;
			_CreatedBy = CreatedBy;
			_ModifiedBy = ModifiedBy;
			_CreatedDate = CreatedDate;
			_ModifiedDate = ModifiedDate;
		}
		public PurchaseRequisitionInfo(DataRow dr)
		{
			if (dr != null)
			{
				_Reference = dr["Reference"] == DBNull.Value ? -1 : (Int32)dr["Reference"];
				_InvNo = dr["InvNo"] == DBNull.Value ? "" : (String)dr["InvNo"];
				_Creditor = dr["Creditor"] == DBNull.Value ? "" : (String)dr["Creditor"];
				_OurRef = dr["OurRef"] == DBNull.Value ? "" : (String)dr["OurRef"];
				_IssueDate = dr["IssueDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["IssueDate"];
				_ReceiptDate = dr["ReceiptDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ReceiptDate"];
				_Amt = dr["Amt"] == DBNull.Value ? 0 : (Double)dr["Amt"];
				_OtherAmt = dr["OtherAmt"] == DBNull.Value ? 0 : (Double)dr["OtherAmt"];
				_Currency = dr["Currency"] == DBNull.Value ? "" : (String)dr["Currency"];
				_PymtRef = dr["PymtRef"] == DBNull.Value ? "" : (String)dr["PymtRef"];
				_PaidDate = dr["PaidDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["PaidDate"];
				_PaymentTerm = dr["PaymentTerm"] == DBNull.Value ? -1 : (Int32)dr["PaymentTerm"];
				_DueDate = dr["DueDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["DueDate"];
				_Description = dr["Description"] == DBNull.Value ? "" : (String)dr["Description"];
				_Contract = dr["Contract"] == DBNull.Value ? "" : (String)dr["Contract"];
				_DeliveryDate = dr["DeliveryDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["DeliveryDate"];
				_ReturnedDate = dr["ReturnedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ReturnedDate"];
				_Department = dr["Department"] == DBNull.Value ? "" : (String)dr["Department"];
				_Remark1 = dr["Remark1"] == DBNull.Value ? "" : (String)dr["Remark1"];
				_Remark2 = dr["Remark2"] == DBNull.Value ? "" : (String)dr["Remark2"];
				_Remark3 = dr["Remark3"] == DBNull.Value ? "" : (String)dr["Remark3"];
				_Mark = dr["Mark"] == DBNull.Value ? (Int16)0 : (Int16)dr["Mark"];
				_TransMitRef = dr["TransMitRef"] == DBNull.Value ? "" : (String)dr["TransMitRef"];
				_TransMitDate = dr["TransMitDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["TransMitDate"];
				_MarkTrm = dr["MarkTrm"] == DBNull.Value ? (Int16)0 : (Int16)dr["MarkTrm"];
				_TransMitStat = dr["TransMitStat"] == DBNull.Value ? "" : (String)dr["TransMitStat"];
				_Receiver = dr["Receiver"] == DBNull.Value ? "" : (String)dr["Receiver"];
				_VendorCode = dr["VendorCode"] == DBNull.Value ? "" : (String)dr["VendorCode"];
				_LineNo = dr["LineNo"] == DBNull.Value ? (Int16)0 : (Int16)dr["LineNo"];
				_CvtRate = dr["CvtRate"] == DBNull.Value ? 0 : (Double)dr["CvtRate"];
				_ReturnRef = dr["ReturnRef"] == DBNull.Value ? "" : (String)dr["ReturnRef"];
				_aYear = dr["aYear"] == DBNull.Value ? -1 : (Int32)dr["aYear"];
				_RealContract = dr["RealContract"] == DBNull.Value ? "" : (String)dr["RealContract"];
				_CreatedBy = dr["CreatedBy"] == DBNull.Value ? "" : (String)dr["CreatedBy"];
				_ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? "" : (String)dr["ModifiedBy"];
				_CreatedDate = dr["CreatedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["CreatedDate"];
				_ModifiedDate = dr["ModifiedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ModifiedDate"];
			}
		}

        public PurchaseRequisitionInfo(DataRowView dr)
        {
            if (dr != null)
            {
                _Reference = dr["Reference"] == DBNull.Value ? -1 : (Int32)dr["Reference"];
                _InvNo = dr["InvNo"] == DBNull.Value ? "" : (String)dr["InvNo"];
                _Creditor = dr["Creditor"] == DBNull.Value ? "" : (String)dr["Creditor"];
                _OurRef = dr["OurRef"] == DBNull.Value ? "" : (String)dr["OurRef"];
                _IssueDate = dr["IssueDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["IssueDate"];
                _ReceiptDate = dr["ReceiptDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ReceiptDate"];
                _Amt = dr["Amt"] == DBNull.Value ? 0 : (Double)dr["Amt"];
                _OtherAmt = dr["OtherAmt"] == DBNull.Value ? 0 : (Double)dr["OtherAmt"];
                _Currency = dr["Currency"] == DBNull.Value ? "" : (String)dr["Currency"];
                _PymtRef = dr["PymtRef"] == DBNull.Value ? "" : (String)dr["PymtRef"];
                _PaidDate = dr["PaidDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["PaidDate"];
                _PaymentTerm = dr["PaymentTerm"] == DBNull.Value ? -1 : (Int32)dr["PaymentTerm"];
                _DueDate = dr["DueDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["DueDate"];
                _Description = dr["Description"] == DBNull.Value ? "" : (String)dr["Description"];
                _Contract = dr["Contract"] == DBNull.Value ? "" : (String)dr["Contract"];
                _DeliveryDate = dr["DeliveryDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["DeliveryDate"];
                _ReturnedDate = dr["ReturnedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ReturnedDate"];
                _Department = dr["Department"] == DBNull.Value ? "" : (String)dr["Department"];
                _Remark1 = dr["Remark1"] == DBNull.Value ? "" : (String)dr["Remark1"];
                _Remark2 = dr["Remark2"] == DBNull.Value ? "" : (String)dr["Remark2"];
                _Remark3 = dr["Remark3"] == DBNull.Value ? "" : (String)dr["Remark3"];
                _Mark = dr["Mark"] == DBNull.Value ? (Int16)0 : (Int16)dr["Mark"];
                _TransMitRef = dr["TransMitRef"] == DBNull.Value ? "" : (String)dr["TransMitRef"];
                _TransMitDate = dr["TransMitDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["TransMitDate"];
                _MarkTrm = dr["MarkTrm"] == DBNull.Value ? (Int16)0 : (Int16)dr["MarkTrm"];
                _TransMitStat = dr["TransMitStat"] == DBNull.Value ? "" : (String)dr["TransMitStat"];
                _Receiver = dr["Receiver"] == DBNull.Value ? "" : (String)dr["Receiver"];
                _VendorCode = dr["VendorCode"] == DBNull.Value ? "" : (String)dr["VendorCode"];
                _LineNo = dr["LineNo"] == DBNull.Value ? (Int16)0 : (Int16)dr["LineNo"];
                _CvtRate = dr["CvtRate"] == DBNull.Value ? 0 : Double.Parse(dr["CvtRate"].ToString());
                _ReturnRef = dr["ReturnRef"] == DBNull.Value ? "" : (String)dr["ReturnRef"];
                _aYear = dr["aYear"] == DBNull.Value ? -1 : (Int32)dr["aYear"];
                _RealContract = dr["RealContract"] == DBNull.Value ? "" : (String)dr["RealContract"];
                _CreatedBy = dr["CreatedBy"] == DBNull.Value ? "" : (String)dr["CreatedBy"];
                _ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? "" : (String)dr["ModifiedBy"];
                _CreatedDate = dr["CreatedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["CreatedDate"];
                _ModifiedDate = dr["ModifiedDate"] == DBNull.Value ? DateTime.Now : (DateTime)dr["ModifiedDate"];
            }
        }
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblPurchaseRequisition");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("Reference", typeof(Int32)),
				new DataColumn("InvNo", typeof(String)),
				new DataColumn("Creditor", typeof(String)),
				new DataColumn("OurRef", typeof(String)),
				new DataColumn("IssueDate", typeof(DateTime)),
				new DataColumn("ReceiptDate", typeof(DateTime)),
				new DataColumn("Amt", typeof(Double)),
				new DataColumn("OtherAmt", typeof(Double)),
				new DataColumn("Currency", typeof(String)),
				new DataColumn("PymtRef", typeof(String)),
				new DataColumn("PaidDate", typeof(DateTime)),
				new DataColumn("PaymentTerm", typeof(Int32)),
				new DataColumn("DueDate", typeof(DateTime)),
				new DataColumn("Description", typeof(String)),
				new DataColumn("Contract", typeof(String)),
				new DataColumn("DeliveryDate", typeof(DateTime)),
				new DataColumn("ReturnedDate", typeof(DateTime)),
				new DataColumn("Department", typeof(String)),
				new DataColumn("Remark1", typeof(String)),
				new DataColumn("Remark2", typeof(String)),
				new DataColumn("Remark3", typeof(String)),
				new DataColumn("Mark", typeof(Int16)),
				new DataColumn("TransMitRef", typeof(String)),
				new DataColumn("TransMitDate", typeof(DateTime)),
				new DataColumn("MarkTrm", typeof(Int16)),
				new DataColumn("TransMitStat", typeof(String)),
				new DataColumn("Receiver", typeof(String)),
				new DataColumn("VendorCode", typeof(String)),
				new DataColumn("LineNo", typeof(Int16)),
				new DataColumn("CvtRate", typeof(Double)),
				new DataColumn("ReturnRef", typeof(String)),
				new DataColumn("aYear", typeof(Int32)),
				new DataColumn("RealContract", typeof(String)),
				new DataColumn("CreatedBy", typeof(String)),
				new DataColumn("ModifiedBy", typeof(String)),
				new DataColumn("CreatedDate", typeof(DateTime)),
				new DataColumn("ModifiedDate", typeof(DateTime))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["Reference"] = _Reference;
			row["InvNo"] = _InvNo;
			row["Creditor"] = _Creditor;
			row["OurRef"] = _OurRef;
			row["IssueDate"] = _IssueDate;
			row["ReceiptDate"] = _ReceiptDate;
			row["Amt"] = _Amt;
			row["OtherAmt"] = _OtherAmt;
			row["Currency"] = _Currency;
			row["PymtRef"] = _PymtRef;
			row["PaidDate"] = _PaidDate;
			row["PaymentTerm"] = _PaymentTerm;
			row["DueDate"] = _DueDate;
			row["Description"] = _Description;
			row["Contract"] = _Contract;
			row["DeliveryDate"] = _DeliveryDate;
			row["ReturnedDate"] = _ReturnedDate;
			row["Department"] = _Department;
			row["Remark1"] = _Remark1;
			row["Remark2"] = _Remark2;
			row["Remark3"] = _Remark3;
			row["Mark"] = _Mark;
			row["TransMitRef"] = _TransMitRef;
			row["TransMitDate"] = _TransMitDate;
			row["MarkTrm"] = _MarkTrm;
			row["TransMitStat"] = _TransMitStat;
			row["Receiver"] = _Receiver;
			row["VendorCode"] = _VendorCode;
			row["LineNo"] = _LineNo;
			row["CvtRate"] = _CvtRate;
			row["ReturnRef"] = _ReturnRef;
			row["aYear"] = _aYear;
			row["RealContract"] = _RealContract;
			row["CreatedBy"] = _CreatedBy;
			row["ModifiedBy"] = _ModifiedBy;
			row["CreatedDate"] = _CreatedDate;
			row["ModifiedDate"] = _ModifiedDate;
			return row;
		}
        #endregion InitTable
    }
}
